﻿using System;
using System.Web;

namespace ValidationFramework.Web.MVC.Extensions
{
	public class MvcValidatedForm : IDisposable
	{
		private bool disposed;
		private readonly string validationScript;
        private readonly HttpResponseBase _httpResponse;

		public MvcValidatedForm(HttpResponseBase httpResponse, string validationScript)
		{
			if (httpResponse == null)
			{
				throw new ArgumentNullException("httpResponse");
			}
			this._httpResponse = httpResponse;

			this.validationScript = validationScript;
		}

		public void Dispose()
		{
			if (!disposed)
			{
				disposed = true;
				_httpResponse.Write("</form>");
				_httpResponse.Write(validationScript);
			}
		}


	}
}
